package com.jss.lanouhn.fristapp.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.jss.lanouhn.fristapp.R;
import com.jss.lanouhn.fristapp.adapters.MessageVPAdapter;
import com.jss.lanouhn.fristapp.fragments.Fragment_Message;
import com.jss.lanouhn.fristapp.fragments.Fragment_Notification;

import java.util.ArrayList;
import java.util.List;

public class ProfileMessageActivity extends AppCompatActivity {
    
    private List<String> tabnames;
    private List<Fragment> listFragments;
    private MessageVPAdapter vpAdapter;
    private TabLayout tb;
    private ViewPager vp;
    private ImageView iv_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile_message);
        initView();
        initData();
        initEvent();
        
    }




    private void initView() {
        tb= (TabLayout) findViewById(R.id.tb_profile_message);
        vp= (ViewPager) findViewById(R.id.vp_profile_message);
        iv_back= (ImageView) findViewById(R.id.btn_back_message);

    }

    private void initData() {
        tabnames=new ArrayList<String>();
        tabnames.add("消息");
        tabnames.add("通知");
        listFragments=new ArrayList<Fragment>();
        listFragments.add(new Fragment_Message());
        listFragments.add(new Fragment_Notification());
        vpAdapter=new MessageVPAdapter(getSupportFragmentManager(),listFragments,tabnames);
        vp.setAdapter(vpAdapter);
        tb.setupWithViewPager(vp);
        vp.setCurrentItem(0);

    }

    private void initEvent() {
       iv_back.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               finish();
           }
       });

    }
}
